﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace MTodo.Model
{
    public class GroupItem : ModelBase
    {
        private Guid _groupId;

        private ObservableCollection<MemoItem> _memoItems;
        /// <summary>
        /// ID
        /// </summary>
        public Guid GroupId 
        {
            get 
            {
                //_groupId = _groupId == null ? Guid.NewGuid() : _groupId;
                return _groupId; 
            }
            set { _groupId = value; }
        }
        /// <summary>
        /// 时间组名
        /// </summary>
        public string GroupName { set; get; }

        /// <summary>
        /// 记事项目
        /// </summary>
        public ObservableCollection<MemoItem> MemoItems 
        {
            get 
            {                
                return _memoItems;
            }
            set
            {
                _memoItems = value;//new ObservableCollection<MemoItem>();               
                this.OnPropertyChanged("MemoNumText");
            }
        }

        public GroupItem()
        {
            _groupId = Guid.NewGuid();
            MemoItems = new ObservableCollection<MemoItem>();
        }
        /// <summary>
        /// 事件的数目文本
        /// </summary>
        public string MemoNumText 
        { 
            get 
            {
                if (MemoItems.Count > 1)
                {
                    return string.Format("[{0} things]", MemoItems.Count);
                }
                else if (MemoItems.Count == 1)
                {
                    return string.Format("[{0} thing]", MemoItems.Count);
                }
                else
                    return string.Empty;
            }
        }
    }
}
